package Controller;

        import repository.CheckRepository;
        import repository.ReleaseRepository;

        import javax.servlet.ServletException;
        import javax.servlet.annotation.WebServlet;
        import javax.servlet.http.HttpServlet;
        import javax.servlet.http.HttpServletRequest;
        import javax.servlet.http.HttpServletResponse;
        import javax.servlet.http.HttpSession;
        import java.io.IOException;
        import java.io.PrintWriter;
        import java.sql.SQLException;

@WebServlet(name = "CheckHtml")
public class CheckController extends HttpServlet{
    private static final long serialVersionUID = 1L;


    public CheckController(){
        super();
        //TODO Auto-generated constructor stub
    }
    public String turn(String str) {

        while (str.indexOf("\n") != -1) {
            str = str.substring(0, str.indexOf("\n")) + "<br>"+ str.substring(str.indexOf("\n") + 1);
        }
        while (str.indexOf("\t") != -1) {
            str = str.substring(0, str.indexOf("\t")) + "&nbsp"+ str.substring(str.indexOf("\t") + 1);
        }

        return str;
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException{
        response.setContentType("text/html;charset=UTF-8");

        PrintWriter out = response.getWriter();
        String Check = request.getParameter("check");
        String ID = request.getParameter("id");
        int i;
        i = Integer.valueOf(ID).intValue();
        System.out.println(Check);
        System.out.println(ID);
        System.out.println(i);

        CheckRepository checkRepository = new CheckRepository();
        boolean release = false;
        try {
            release = checkRepository.ChangeCheck(Check,i);
        } catch (SQLException e) {
            e.printStackTrace();
        }

        System.out.println("check="+release);

    }
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
